package com.night.student.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.night.common.entity.PageBean;
import com.night.common.entity.student.Evaluate;
import com.night.common.entity.student.EvaluateVo;
import com.night.common.entity.student.ShowEvaluate;
import com.night.student.mapper.EvaluateMapper;
import com.night.student.service.EvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author Mr.Wang
 * @ClassName: EvaluateServiceImpl
 * @Description: //TODO
 * @date: 2022/10/20-15:04
 */
@Service
public class EvaluateServiceImpl implements EvaluateService {
    @Autowired
    EvaluateMapper evaluateMapper;

    @Override
    public void insert(Evaluate evaluate) {
        evaluateMapper.insert(evaluate);
    }

    @Override
    public void update(Evaluate evaluate) {
        evaluateMapper.update(evaluate);
    }

    @Override
    public List<Evaluate> getUnevaluate(int studentId) {
        return evaluateMapper.getByStudentId(studentId);
    }

    @Override
    public PageBean<List<Evaluate>>  getByCondition(EvaluateVo evaluateVo) {
        int pageSize = 5;
        PageBean<List<Evaluate>> pageBean = new PageBean<>();
        Page p = PageHelper.startPage(evaluateVo.getPage(),pageSize);
        List<Evaluate> data = evaluateMapper.getByCondition(evaluateVo.getEvaluate());
        pageBean.setData(data);
        pageBean.setCurrPage(evaluateVo.getPage());
        pageBean.setPageSize(pageSize);
        pageBean.setTotalNum((int) p.getTotal());
        pageBean.setTotalPages(p.getPages());
        return pageBean;
    }

    @Override
    public ShowEvaluate getScoreByTeach(int id) {
        return evaluateMapper.getScoreByTeach(id);
    }

    @Override
    public ShowEvaluate getScoreByCourse(int[] ids) {
        return evaluateMapper.getScoreByCourse(ids);
    }
}
